package com.levi.lambda;

import jdk.internal.org.objectweb.asm.tree.analysis.Value;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author shentong
 * @date 2022/1/10 9:22 PM
 * @description
 */
public class LambdaTest {
    public static void main(String[] args) {
        String[] lanuage = {"java","php","python","c","c++"};
        List<String> lanuageList = Arrays.asList(lanuage);
        //Lambda写法遍历集合
        lanuageList.forEach(value->System.out.println(value+","));
        System.out.println("-----------");

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                System.out.println("Runable接口～～～～");
            }
        };
        //Lambda写法  Runable是一个单方法接口
        Runnable runnable1 = ()-> System.out.println("runbale1接口～～～～");
        //Lambda对集合进行排序
        Arrays.sort(lanuage, String::compareTo);//对数组进行排序
        List<String> collect = lanuageList.stream().sorted(String::compareTo).collect(Collectors.toList());//对集合进行排序
    }
}
